package com.stgy.lease.common.exception;

import com.stgy.lease.common.result.ResultCodeEnum;
import lombok.Data;

/**
 * ClassName:StgyException
 * Package:com.stgy.lease.common.exception
 * Description:Exception编译时异常 RuntimeException运行时
 *
 * @Author:helei
 * @Create:2024/8/28 - 15:50
 */
@Data
public class StgyException extends RuntimeException {
    private Integer code;
    private String message;
    //接收真实的异常对象
    private Throwable throwable;

    public StgyException(Integer code, String message) {
        this(code, message, null);
    }

    public StgyException(Integer code, String message, Throwable throwable) {
        this.code = code;
        this.message = message;
        this.throwable = throwable;
    }

    public StgyException(ResultCodeEnum resultCodeEnum) {
        this(resultCodeEnum.getCode(), resultCodeEnum.getMessage());
    }

    public StgyException(ResultCodeEnum resultCodeEnum, Throwable throwable) {
        this(resultCodeEnum.getCode(), resultCodeEnum.getMessage(), throwable);
    }


    private StgyException() {
    }
}
